import 'package:bottom_sheet_flutter/utils/color_util/color_util.dart';
import 'package:bottom_sheet_flutter/utils/style_util/style_util.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/src/size_extension.dart';
import '../widgets/text_widget/text_widget.dart';
import 'action_bottom_sheet/action_bottom_sheet.dart';
import 'gold_coins_give/gold_coins_give.dart';
import 'package:get/get.dart';


/// @className : bottom_sheet
/// @date 2022/07/17 00:22
/// @author : xiaohai
/// @description : 底部抽屉

class BottomSheetPage extends StatefulWidget {
  const BottomSheetPage({Key? key}) : super(key: key);

  @override
  _BottomSheetPageState createState() => _BottomSheetPageState();
}

class _BottomSheetPageState extends State<BottomSheetPage> {

  /// action列表
  late final List itemList = [{"title":"金币赠送","index":1},{"title":"动作抽屉层","index":2}];


  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      appBar: AppBar(title: const Text("BottomSheet")),
      body: Builder(builder: (content){
        return ListView.builder(
          itemCount: itemList.length,
          itemBuilder: (BuildContext context, int index) {
              Map item = itemList[index];
              return  buildItemWidget(item["index"],item["title"]);
          });
      }),
    );
  }

  /// 构建item组件
  Widget buildItemWidget(int? index, String? title){
    return  InkWell(
      child: Container(
        child:Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              padding: EdgeInsets.only(left: 24.w,right: 24.w),
              alignment: Alignment.centerLeft,
              height: 120.w,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  textWidget(title, TS_000000_28_W4),
                  Image.asset("assets/images/right_arrow.png",
                      width: 48.w,
                      height: 48.w)
                ],
              ),
            ),
            Container(
              margin: EdgeInsets.only(left: 24.w),
              color: ColorsUtil.hexColor(0xEBEDF2),height: 1.w)
          ],
        )
      ),
      onTap: (){
        if(index == 1){
          Get.to(() => const GoldCoinsGive());
        }else if(index == 2){
          Get.to(() => const ActionBottomSheet());
        }
      },
    );
  }

}
